package fr.pioug.gdocs.service;

import javax.swing.*;

import org.apache.log4j.*;

/**
 * @author a011228
 * @version
 */
public class LogService {
	/**
	 * @param pKey
	 * @param pClass
	 */
	@SuppressWarnings("unchecked")
	public static void debug(String pKey, Class pClass) {
		Logger.getLogger(pClass).debug(
				ResourceService.getInstance().getValue(pKey));
	}

	/**
	 * @param pKey
	 * @param pClass
	 */
	@SuppressWarnings("unchecked")
	public static void info(String pKey, Class pClass) {
		Logger.getLogger(pClass).info(
				ResourceService.getInstance().getValue(pKey));
	}

	/**
	 * @param pKey
	 * @param pClass
	 * @param pException
	 */
	@SuppressWarnings("unchecked")
	public static void error(String pKey, Class pClass, Exception pException) {
		Logger.getLogger(pClass).error(
				ResourceService.getInstance().getValue(pKey), pException);

	}

	/**
	 * @param pKey
	 * @param pClass
	 * @param pException
	 */
	@SuppressWarnings("unchecked")
	public static void showError(String pKey, Class pClass, Exception pException) {
		Logger.getLogger(pClass).error(
				ResourceService.getInstance().getValue(pKey), pException);
		JOptionPane.showMessageDialog(null, ResourceService.getInstance()
				.getValue(pKey), ResourceService.getInstance().getValue(
				"error.lib"), JOptionPane.ERROR_MESSAGE);

	}

	/**
	 * @param pClass
	 * @return
	 */
	@SuppressWarnings("unchecked")
	public static boolean isDebugEnabled(Class pClass) {
		return Logger.getLogger(pClass).isDebugEnabled();
	}
}
